clear all
cd "~/Box Sync/Replication_AJPS_0215"
eststo clear
set more off
set mem 900m
use "Final_Analysis_Data.dta"

xtset Dist_IRN election_id

gen Prof_Percent_Avg = (prof_PctProf_M + prof_PctProf_R)/2

codebook Prof_Percent_Avg

*Calculating Proficiency IQR in Sample;
egen Perc25_Prof_Percent_Avg = pctile(Prof_Percent_Avg),  p(25) by(FY)
egen Perc75_Prof_Percent_Avg = pctile(Prof_Percent_Avg),  p(75) by(FY)

gen In_IQR_Prof = .
replace In_IQR_Prof = 1 if Perc25_Prof_Percent_Avg < Prof_Percent_Avg  & Prof_Percent_Avg< Perc75_Prof_Percent_Avg
replace In_IQR_Prof = 0 if Prof_Percent_Avg > Perc75_Prof_Percent_Avg
replace In_IQR_Prof = 0 if Prof_Percent_Avg < Perc25_Prof_Percent_Avg

twoway (scatter Perc75_Prof_Percent_Avg FY) (scatter Perc25_Prof_Percent_Avg FY)
*graph export IQR_Prof.pdf, replace
corr Prof_Percent_Avg AYP_Not_Met_2

*Table A11 Replication
eststo: xi: reg Pass AYP_Not_Met_2 i.FY if In_IQR_Prof == 1, vce(cluster Dist_IRN)

estadd local Dist_FE "No"
estadd local Year_FE "Yes"
estadd local Ac_Desig "No"

*OLS District Covariates
eststo:  xi: reg Pass AYP_Not_Met_2 i.FY Millage_Real Per_Pupil_Value Total_Expend Instruction_Expend PctEnrollBlack  PctEnrollHisp LEP_PctEnroll EconDisad_PctEnroll Disabled_PctEnroll Ln_Enroll2 if In_IQR_Prof == 1, vce(cluster Dist_IRN)

estadd local Dist_FE "No"
estadd local Year_FE "Yes"
estadd local Ac_Desig "No"


*OLS District Covariates with Mills, Private School, Own Housing (No Percentage Improvement)
eststo: xi: reg Pass AYP_Not_Met_2 i.FY Millage_Real Per_Pupil_Value Total_Expend Instruction_Expend PctEnrollBlack  PctEnrollHisp LEP_PctEnroll EconDisad_PctEnroll Disabled_PctEnroll Ln_Enroll2 Mills household_privateenrollment_perc housing_own_percent if In_IQR_Prof == 1, vce(cluster Dist_IRN)

estadd local Dist_FE "No"
estadd local Year_FE "Yes"
estadd local Ac_Desig "No"


*OLS District Covariates with Mills, Private School, Own Housing, Designation (No Percentage Improvement)
eststo: xi: reg Pass AYP_Not_Met_2 i.FY Millage_Real Per_Pupil_Value Total_Expend Instruction_Expend PctEnrollBlack  PctEnrollHisp LEP_PctEnroll EconDisad_PctEnroll Disabled_PctEnroll Ln_Enroll2 Mills household_privateenrollment_perc housing_own_percent i.Designation if In_IQR_Prof == 1, vce(cluster Dist_IRN)

estadd local Dist_FE "No"
estadd local Year_FE "Yes"
estadd local Ac_Desig "Yes"


*District Fixed Effects

eststo: xi: xtreg Pass AYP_Not_Met_2 i.FY Millage_Real Per_Pupil_Value Total_Expend Instruction_Expend PctEnrollBlack  PctEnrollHisp LEP_PctEnroll EconDisad_PctEnroll Disabled_PctEnroll Ln_Enroll2 Mills i.Designation if In_IQR_Prof == 1, fe vce(cluster Dist_IRN)
estadd local Dist_FE "Yes"
estadd local Year_FE "Yes"
estadd local Ac_Desig "Yes"

*esttab using Table_A11.tex, note("Heteroskedasticity robust standard errors clustered at the district level in parentheses") label  se star(* 0.05 ** 0.01 *** 0.001) r2 scalars("Year_FE Year Fixed Effects" "Dist_FE District Fixed Effects" "Ac_Desig Academic Designations")  title(Linear Probability Models for Levy Passage for Districts in Proficency IQR) drop( _IFY_2004 _IFY_2005 _IFY_2006 _IFY_2007 _IFY_2008 _IFY_2009 _IFY_2010 _IFY_2011 _IFY_2012 _IDesignati_2 _IDesignati_3 _IDesignati_4 _IDesignati_5 _IDesignati_6) replace
eststo clear
